package com.kaishengit.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.kaishengit.entity.Employee;
import com.kaishengit.service.FileTypeService;
import com.kaishengit.util.web.ServletUtil;

public class NewFileType extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private FileTypeService service=new FileTypeService();

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		ServletUtil.forward(request, response, "/newFileType");
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		HttpSession session=ServletUtil.getSession(request);
		Employee employee=(Employee) session.getAttribute("employee");
		String pid=(String) session.getAttribute("pid");
		
		String fileTypeName=request.getParameter("fileTypeName");
		
		service.save(fileTypeName,pid,employee.getId());
		
		ServletUtil.redirect(response, "fileType.jspx");
	}

}
